<%@ include file="/common/taglibs.jsp"%>
<%
response.setHeader("Cache-Control","no-cache"); //HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", 0); //prevent caching at the proxy server
%>

<head>
    <title><fmt:message key="articulolist.title"/></title>
    <meta name="heading" content="<fmt:message key='articulolist.heading'/>"/>    
</head>

<form:form id="articuloList">

	<fieldset style="width: 300px">
	<legend><fmt:message key="common.filtros.busqueda"/></legend>
		
		<br/><div>
			<fmt:message key="common.articulo"/><br/>
		    <input type="text" id="deArticulo" name="deArticulo" class="text medium"/>
		</div>
		<br/>	
		<div>
			<fmt:message key="common.codigo"/><br/>
			<input type="text" id="coCodigoArticulo" name="coCodigoArticulo" class="text medium"/>			
		</div><br/>
		<div>
			<fmt:message key="common.categoria"/><br/>
			<select id="coCategoria" name="coCategoria" class="text medium">
				<option value="0"><fmt:message key="label.itemdefault"/></option>
				<c:forEach var="categoria" items="${categorias}" varStatus="status">	
					<option value="${categoria.id}">${categoria.deCategoria}</option>
				</c:forEach>			
			</select>
		</div><br/>					
		
		<div>
			<fmt:message key="common.maneja.stock"/><br/>
			<select id="stManejaStock" name="stManejaStock" class="text mediumlarge">
				<option value="-"><fmt:message key="label.itemdefault"/></option>
				<option value="PC"><fmt:message key="common.maneja.stock.punto.canje"/></option>
				<option value="AP"><fmt:message key="common.maneja.stock.almacen.principal"/></option>
				<option value="NM"><fmt:message key="common.no.maneja.stock"/></option>
			</select>
		</div><br/>
		<div>
			<fmt:message key="common.maneja.serie"/><br/>
			<select id="stManejaSerie" name="stManejaSerie" class="text medium">
				<option value="-"><fmt:message key="label.itemdefault"/></option>
				<option value="Y"><fmt:message key="common.yes"/></option>
				<option value="N"><fmt:message key="common.no"/></option>
			</select>
		</div><br/>				
		<div>
			<input type="button" onclick="buscarArticulos()" value="<fmt:message key="button.search"/>"/>
		</div>					
		</fieldset><br/><br/>
	
<table id="articulos" cellpadding="0" class="table" cellspacing="0" style="width: 750px" > 
	<thead> 
		<tr> 
            <th scope="col"><fmt:message key="common.articulo"/></th>
            <th scope="col"><fmt:message key="common.categoria"/></th>
            <th scope="col"><fmt:message key="common.codigo.articulo"/></th>
            <th scope="col"><fmt:message key="common.unidad.medida"/></th>
            <th scope="col"><fmt:message key="common.maneja.tipoarticulo"/>?</th>            
            <th scope="col"><fmt:message key="common.stock.actual"/></th>            
            <th scope="col"><fmt:message key="common.stock.disponible"/></th>		
		</tr>
	</thead> 
	<tbody id="articulosbody">
		<tr id="pattern" style="display:none;">
			<td> 
				<span id="tableArticulo">Articulo</span>						
			</td>
			<td> 
				<span id="tableCategoria">Categoria</span>						
			</td>	
			<td> 
				<span id="tableCodigo">Codigo</span>						
			</td>	
			<td> 
				<span id="tableUnidadMedida">Unidad Medida</span>						
			</td>
			<td> 
				<span id="tableStock">Maneja Stock</span>						
			</td>						
			<td> 
				<span id="tableStockActual">Stock Actual</span>						
			</td>
			<td> 
				<span id="tableStockDisponible">Stock Disponible</span>						
			</td>
		</tr> 	
		<c:forEach var="articulo" items="${articulos}" varStatus="status">	
			<c:choose>
				  <c:when test="${status.index % 2 == 0}"><tr class="odd" ></c:when>
				  <c:otherwise><tr class="even" ></c:otherwise>
			</c:choose> 
            	<td>
					<a href="javascript:void(0)" title="Valor" onClick="Modalbox.hide({beforeHide: function(){
											$('articuloid').value = '${articulo.id}',$('articuloNameid').value = '${articulo.deArticulo}',$('deUnidadMedida').value = '${articulo.deUnidadMedida}',$('coArticulo').value = '${articulo.coCodigoArticulo}',$('stockDisponible').value = '${articulo.vaStockDisponible}'}})">					
                    	${articulo.deArticulo}
                    </a> 
				</td>
				<td>
                    ${articulo.deCategoria}
                </td> 
                <td>
                    ${articulo.coCodigoArticulo}
                </td>
                <td>
                    ${articulo.deUnidadMedida}
                </td>
                <td>
                	<c:choose>
                		<c:when test="${articulo.stManejaStockPuntoCanje == 'Y'}">
                			<fmt:message key='common.maneja.stock.punto.canje'/>
                		</c:when>
                		<c:when test="${articulo.stManejaStockAlmPrincipal == 'Y'}">
                			<fmt:message key='common.maneja.stock.almacen.principal'/>
                		</c:when>                		
                		<c:when test="${articulo.stNoManejaStock == 'Y'}">
                			<fmt:message key='common.no.maneja.stock'/>
                		</c:when>
                		 <c:when test="${articulo.stInstantaneoNormal == 'Y'}">
		               		<fmt:message key='common.maneja.premioinstantaneo'/>
		               	</c:when>
                	</c:choose>
                </td>                               
                <td>
                	${articulo.vaStockActual}
                </td>
                <td>
                	${articulo.vaStockDisponible}
                </td>
           </tr>
        </c:forEach>				
	</tbody>
</table> 
</form:form>

<script type='text/javascript' src="<c:url value="/dwr/interface/WizardArticuloService.js"/>"></script>